#include <iostream>
#define LL long long
using namespace std;

const int kMaxN = 1e6 + 10;

LL a[kMaxN], sum[kMaxN];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, k;
  LL opt = 0;

  cin >> n >> k;
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    sum[i] = sum[i - 1] + a[i];
    if (i >= k) {
      opt = max(opt, sum[i] - sum[i - k]);
    }
  }
  cout << sum[n - 1] - opt << "\n";
  return 0;
}